{% extends "swaps/base.html" %}

{% load i18n %}
{% load avatar_tags %}
{% load account_tags %}
{% load humanize %}
{% load pagination_tags %}
{% load tagging_tags %}
{% load wakawaka_tags %}
{% load markup %}
{% load restructuredtext %}
{% load threadedcommentstags %}
{% load theme_tags %}

{% block head_title %}{% blocktrans %}All Open Offers{% endblocktrans %}{% endblock %}

{% block body %}
    
    <p><a href="#" id="what-toggle">Toggle What is this?</a></p>
    <div id="swaps-what" style="display: none; font-size: 90%; ">
        <p>A much simpler version of <a href="http://www.swaptree.com" target="_blank" >SwapTree</a>.</p>
        <p>Trade anything for anything with any member of this social network.</p>
    </div>
    
    <p><a href="#" id="how-toggle">Toggle How does this work?</a></p>
    <div id="swaps-how" style="display: none; font-size: 90%; ">
        <p>
            Make an offer (of anything you are willing to give), ask for something you want to take in exchange.
            Could be books, CDs, DVDs, games, work, gear, money - anything.
        </p>
        <p>
            Maybe somebody will propose a swap of something of theirs for your offer.
            If so, the proposed swap goes into your <b>Proposed to you</b> page and their <b>Proposed by you</b> page.
        </p>
        <p>
            Your offer remains on the <b>Open offers</b> page so you may get other proposals, until you finally accept a swap.
            (Their offer is not open; it is bound to their proposal unless you accept the proposed swap, or they cancel their proposal.)
        </p>
        <p>
            You can either accept or reject their proposal.
            Or you can discuss it in swap comments, and maybe get them to sweeten their offer.
        </p>
        <p>
            If you accept the proposal, the swap goes into the <b>Accepted swaps</b> page of both participants.
            It is up to the participants to deliver on their promises.
        </p>
        <p>
            If you reject the proposal, the swap goes into the <b>Dead swaps</b> page of both participants,
            and both offers are returned to the <b>Open offers</b> page.
        </p>
    </div>
    
    <h1>{% trans "All Open Offers" %}</h1>
    
    {% if offers %}
        
        {% autopaginate offers %}
        
        <table class="bookmarks">
            {% for offer in offers %}
                <tr class="{% cycle odd,even %}">
                    <td>
                        <h2><a href="{{ offer.get_absolute_url }}">{{ offer.short_description }}</a></h2>
                        <p>Offering: {{ offer.offering|truncatewords:15 }}</p>
                        <p>Want: {{ offer.want|truncatewords:15 }}</p>
                    </td>
                    <td>
                        {% ifnotequal user offer.offerer %}
                            <form action="{% url propose_swap offer.id %}" method="GET">
                                <input type="submit" value="{% trans "Propose Swap" %}" />
                            </form>
                        {% endifnotequal %}
                    </td>
                    <td class="meta">
                        {% avatar offer.offerer 40 %}
                        <p>
                            <b>Offered by:</b><br /><a href="{% url profile_detail offer.offerer.username %}">{% user_display offer.offerer %}</a>
                            on {{ offer.offered_time|date }}
                        </p>
                        {# @@@ I've seen this multiple places -- should be inclusion tag #}
                        <div class="blog-tags">
                            {% silk "tag_blue" %}
                            {% tags_for_object offer as tags %}
                            {% for tag in tags %}
                                <a href="/tags/{{ tag }}">{{ tag }}</a>
                            {% endfor %}
                        </div>
                    </td>
                </tr>
            {% endfor %}
        </table>
        
        {% paginate %}
        
    {% else %}
        <p>No open offers.</p>
    {% endif %}
    
{% endblock %}

{% block extra_body %}
<script>
    $(document).ready(function(){
        
        $('a#what-toggle').click(function() {
            $('#swaps-what').toggle(400);
            return false;
        });
        
        $('a#how-toggle').click(function() {
            $('#swaps-how').toggle(400);
            return false;
        });
    });
</script>
{% endblock %}
